package pack04_covid_merge;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author lilulu
 * @date 2023/2/11 13:16
 */
public class CovidCountBean  implements Writable {
    /*
1:Hadoop中自定义的类必须要能够被序列化和反序列化 -----》实现Writable接口
2:如果自定义类作为K2，则该类还要能够被排序       -----》WritableComparable
*/
    private int cases; //累计确诊病例
    private int deaths; // deaths累计死亡病例

    @Override
    public String toString() {
        return
               cases +
                "\t" + deaths ;
    }

    public int getCases() {
        return cases;
    }

    public void setCases(int cases) {
        this.cases = cases;
    }

    public int getDeaths() {
        return deaths;
    }

    public void setDeaths(int deaths) {
        this.deaths = deaths;
    }

    public CovidCountBean() {
    }

    public CovidCountBean(int cases, int deaths) {
        this.cases = cases;
        this.deaths = deaths;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(cases);
        dataOutput.writeInt(deaths);

    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.cases=dataInput.readInt();
        this.deaths=dataInput.readInt();
    }



}
